package com.easyapi.server.service.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.easyapi.common.param.datasource.AddDatasourceParam;
import com.easyapi.common.param.datasource.DataSourcePageParam;
import com.easyapi.common.utils.BaseResponse;
import com.easyapi.common.vo.datasource.DataSourceListVo;
import com.easyapi.common.vo.datasource.DataSourcePageVo;
import com.easyapi.common.vo.metadata.TableStruct;
import com.easyapi.dao.entity.api.ApiCenterDatasource;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author  javadadi
 */
public interface DataSourceService extends IService<ApiCenterDatasource> {

    boolean saveDataSource(AddDatasourceParam param);

    Page<DataSourcePageVo> page(DataSourcePageParam param);

    boolean removeDataSource(Long id);

    boolean datasourceOperation(Long Id, String action);


    boolean testDataSourceConnection(AddDatasourceParam param);

    List<String> listAllDatabases(Long id, String databaseName);

    List<String> listAllTables(Long id, String databaseName, String tableName);

    BaseResponse<List<TableStruct>> getTableStruct(Long id, String databaseName, String tableName);

    String getCreateSql(Long id, String databaseName, String tableName);

    List<List<String>> getTableData(Long id, String databaseName, String tableName);

    Boolean initDruidDatasource();

    List<DataSourceListVo> listDataSource();

    List<DataSourceListVo> listDatasourceByProjectId(Long projectId);
}
